import { createApp } from 'vue';
// permission 权限文件
import './config/permission';

import {hasRole} from '@/config/hasRole'
// element
import 'element-plus/theme-chalk/display.css';

// ElementPlus from 'element-plus';
import { ElMessage } from 'element-plus'
// element theme change
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/vite_admin";
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { download } from '@/utils/request'
import {useDict} from "@/utils/dict"


import App from './App.vue';
const app = createApp(App);


// 全局方法挂载
app.config.globalProperties.$getDicts = getDicts
app.config.globalProperties.$useDict = useDict
app.config.globalProperties.$getConfigKey = getConfigKey
app.config.globalProperties.$parseTime = parseTime
app.config.globalProperties.$resetForm = resetForm
app.config.globalProperties.$addDateRange = addDateRange
app.config.globalProperties.$selectDictLabel = selectDictLabel
app.config.globalProperties.$selectDictLabels = selectDictLabels
app.config.globalProperties.$download = download
app.config.globalProperties.$handleTree = handleTree

app.config.globalProperties.$border =true
//全局图标大小设定
  app.config.globalProperties.iconSize ="14"
  app.config.globalProperties.iconStrokeWidth ="3"
  app.config.globalProperties.iconTheme ="outline"


  // 将函数挂载到全局
//app.config.globalProperties.Dialog = Dialog;
app.config.globalProperties.Success= (msg) => {
  ElMessage({
    message: msg,
    type: 'success',
  })
}
app.config.globalProperties.Warning= (msg) => {
  ElMessage({
    message: msg,
    type: 'warning',
  })
}
app.config.globalProperties.Error= (msg) => {
  ElMessage.error(msg)
}



import { VueClipboard } from '@soerenmartius/vue3-clipboard';
app.use(VueClipboard);

// layout components
import layoutComp from './layouts/components/export';
layoutComp(app);

// router
import router from './router/index';
app.use(router);

// vuex
import store from '@/store';
app.use(store);

app.use(hasRole)

// 按需注册方式
// import elementPlus from './plugin/el-comp';
// 注册 elementPlus组件/插件
// elementPlus(app);
// // 完整引入

// 注册字节跳动图标
import iconPark from './plugin/icon-park';
iconPark(app);

import loadI18n from './plugin/i18n';
loadI18n(app);

app.mount('#app');
